package priv.wjh.study.oauth;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import java.security.Principal;

@Controller
public class AppController {
	@GetMapping("hello")
	public ModelAndView welcome(Principal principal) {
		// 获取登录用户信息
		ModelAndView mav = new ModelAndView();
		mav.setViewName("welcome");
		mav.addObject("name", principal.getName());
		return mav;
	}

	@GetMapping("/")
	public ModelAndView home(Principal principal, HttpServletResponse response) {
		ModelAndView mav = new ModelAndView();
		mav.setViewName("index");
		response.setHeader("X-Frame-Options", "allow-from http://localhost:8080");
		return mav;
	}
}
